// import { request } from "@/utils/request"; 
import { request } from "../../utils/http";

// 登录
const accountApi = {
  /**
   * @description      用户登录的api
   * @param loginValues 
   * @returns 
   */
  userLogin: (loginValues: userInfoType) => {
    return request.post<{
      id: string;
      number: string;
      account: string;
      userTypeId: string;
      flag: number;
      openid: string | null;
      fkRoleId: string;
      token: string;
    }>("/api/chcsLogin", loginValues)
  },
  /**
   * @description  用户登陆之后的权限管理
   * @param userid 
   * @returns 
   */
  getUserRole: (userid: string) => {
    return request.post("/api/getCHCSUserPower", {
      userid: userid
    })
  },
  /**
   * @description  获取用户信息
   */
  getUserInfo: (id: string) => {
    return request.post<drDataInfo>("/api/getDoctorByUserId", {
      userId: id
    })
  },
  /**
   * @description  获取统计数据
   * @param  drId  医生id
   */
  getStatisticsData: (drId: string) => {
    return request.post<CountDataType>("/api/getStatisticsByDId", {
      doctorId: drId,
    });
  }
}

export {
  accountApi
} 



/**@description 用户信息 */
class userInfoType {
  /**@description 用户名 */
  account: string
  /**@description 用户id */
  pwd: string
  constructor(account: string, pwd: string) {
    this.account = account
    this.pwd = pwd
  }
}
/**@description  医生具体信息 */
interface Role {
  id: string;
  name: string;
  description: string;
  createTime: string;
  creatorId: string;
  flag: number;
} 
/**@description  医生的详细信息的类型 */
export interface drDataInfo {
  id: string;
  number: string;
  userId: string;
  name: string;
  roleId: string;
  picture: string;
  tel: string;
  gender: string;
  description: string;
  adept: string;
  createTime: string;
  creatorId: string;
  msgStatus: number;
  status: number;
  flag: number;
  role: Role;
}

/**@description  统计数据类型 */
interface CountDataType {
  signCount: {
    /**@description  已签约 */
    signCount: number;
  };
  totalCount: {
    /**@description 居民总数 */
    totalCount: number;
  };
  /**@description  待签约 */
  notSignCount: number;
  /**@description  待处理服务  */
  serviceCount: number;
  /**@description  服务总量 */
  totalServiceCount: number;
  score: {
    /**@description  服务评价 */
    score: number;
  };
}